package io.gitee.zhucan123.core.infrastructure.mvc;

import org.springframework.data.domain.Page;
import org.springframework.stereotype.Component;

import java.util.function.Function;


/**
 * @author: zhuCan
 * @date:
 * @description:
 */
@Component
public class PageAssembler<T> implements Function<Page<T>, PageDtoOut<T>> {
  @Override
  public PageDtoOut<T> apply(Page<T> ts) {

    return PageDtoOut.<T>builder()
        .pageNum(ts.getNumber() + 1)
        .pageSize(ts.getSize())
        .totalNums(ts.getTotalElements())
        .content(ts.getContent())
        .build();
  }
}
